<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="/rucdbcourse/views/images/ruc_logo_icon.jpg">
    <title>数据库系统概论实验评分系统</title>
    <link href="/rucdbcourse/views/css/micpback.css" rel="stylesheet">
    <!-- Bootstrap core CSS -->
    <link href="/rucdbcourse/views/css/bootstrap.min.css" rel="stylesheet">
    <link href="/rucdbcourse/views/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="/rucdbcourse/views/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="/rucdbcourse/views/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.css" rel="stylesheet" type="text/css" media="screen" />
    <link rel="stylesheet" href="/rucdbcourse/views/css/owl.carousel.css" type="text/css">
    <!-- Custom styles for this template -->
    <link href="/rucdbcourse/views/css/style.css" rel="stylesheet">
    <link href="/rucdbcourse/views/css/style-responsive.css" rel="stylesheet" />
    <link rel="stylesheet" media="screen" href="/rucdbcourse/views/css/zzsc.css" />
    <link rel="stylesheet" media="screen" href="/rucdbcourse/views/css/loading-bar.css" />
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
    <style>
	/*
	 * override the default CSS as an example
	 */
	
	#loading-bar .bar {
	  background: #C43C3C;
	}
	#loading-bar-spinner .spinner-icon {
	  border-top-color:  #C43C3C;
	  border-left-color: #C43C3C;
	}
	#loading-bar .peg {
	  -moz-box-shadow: #C43C3C 1px 0 6px 1px;
	  -ms-box-shadow: #C43C3C 1px 0 6px 1px;
	  -webkit-box-shadow: #C43C3C 1px 0 6px 1px;
	  box-shadow: #C43C3C 1px 0 6px 1px;
	}
    </style>
</head>

<body>
    <div ng-app="mindex" ng-controller="mindexCtrl">
        <header class="header white-bg" style="width:83%">
            <div class="sidebar-toggle-box">
                <div data-original-title="Toggle Navigation" data-placement="right" class="icon-reorder tooltips" id="toggle-sidebar"></div>
            </div>
        </header>
        <!--header end-->
       
        <!--sidebar start-->
        <aside>
            <div id="sidebar" class="nav-collapse " style="width:17%">
                <!-- sidebar menu start-->
                <ul class="sidebar-menu">
                    <div class="welcome">
                        <img src="/rucdbcourse/views/images/2.jpg" class="img-circle pull-left">
                        <p class="text-center">
                            <br>
                            <b>WELCOME</b>
                            <br>
                            <span id="name">管理员<br></span>
                        </p>
                    </div>
                    <li class="" ng-click="addTeacher()">
                        <a class="">
                            <i class="icon-home"></i>
                            <span style="padding-left:2px">教师账号</span>
                        </a>
                    </li>
                    <li class="" ng-click="manageStu()">
                        <a class="">
                            <i class="icon-home"></i>
                            <span style="padding-left:2px">管理学生</span>
                        </a>
                    </li>
                  
                </ul>
                <!-- sidebar menu end-->
            </div>
        </aside>
        <!--sidebar end-->
        <div id="sidenav-overlay" class=""></div>
		<section id="container" class="">
			<aside class="aside-width"></aside>
			<!--main content start-->
			<!--展示首页-->
			<section id="main-content">
				<section class="wrapper" ng-show="moduleNum === 1">
				<h2>添加教师账号信息</h2>
					<span>姓名</span>
					<input type="text" ng-model="tname" name="tname" id="tname"><br><br>
					
					<span>密码</span>
					<input type="password" ng-model="passwd" name="passwd" id="passwd"><br><br>
					
					<span>邮箱</span>
					<input type="text" ng-model="email" name="email" style="width:260px" id="email"><br><br>
					
					<span>学校</span>
                    <select id="school" style="width:160px" ng-init="selectedUniversity = universities[0]" ng-model="selectedUniversity" ng-options="x for x in universities">
                    <option value="" disabled selected>请选择学校</option>
                  </select>
                  <br><br>
                  <span>专业</span>
					<input type="text" ng-model="major" name="major" id="major"><br><br>
                  
                    <span >序号</span>
                    <select style="" style="width:60px" ng-init="selecteSequence = sequences[0]" ng-model="selectedSequence" ng-options="x for x in sequences" >
                    <option value="" disabled selected>请选择课程序号</option>
                     </select>
                    <br><br>
                     <span >年份</span>
                    <select style="" style="width:60px" ng-init="selecteYear = years[0]" ng-model="selectedYear" ng-options="x for x in years" >
                    <option value="" disabled selected>请选择申请年份</option>
                     </select>
                    <br><br>
                    <input type="submit" value="添加" style="width:80px;" ng-click="submitTeacher()">
                    <br><br>
                    <span>账号：{{account}}</span><br><br>
                    <span>密码：{{accPasswd}}</span>
				</section>
				<!-- section teacher ended -->
				<section class="wrapper" ng-show="moduleNum === 2">
					<h3>删除某学生账号</h3>
					<span>账号</span>
					<input type="text" ng-model="stuacc" name="stuacc" id="stuacc">
					<input type="submit" value="删除" style="width:80px;" ng-click="destu()">
					<br><br>
					
					<h3>删除某学生答题记录</h3>
					<span>账号</span>
					<input type="text" ng-model="stuacc2" name="stuacc2" id="stuacc2">
					<input type="submit" value="删除记录" style="width:80px;" ng-click="desturecord()">
                    <br><br>
                    <span>学生ID</span>
                    <input type="text" ng-model="stuacc3" name="stuacc3" id="stuacc3">
                    <input type="submit" value="删除记录" style="width:80px;" ng-click="desturecord_by_id()">
					<br><br>
					
					<h3>查询学生userid</h3>
					<span>账号</span>
					<input type="text" ng-model="stuacc4" name="stuacc4" id="stuacc4">
					<input type="submit" value="查询ID" style="width:80px;" ng-click="askid()">
					<br><br>
					
					
				</section>
    </div>
    <script type="text/javascript" src="/rucdbcourse/views/js/jquery.js"></script>
    <script src="/rucdbcourse/views/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/lib/angular.min.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/js/loading-bar.js"></script>
    <script src="/rucdbcourse/views/js/jquery.easing.min.js" type="text/javascript"></script>
    <script src="/rucdbcourse/views/js/zzsc.js" type="text/javascript"></script>
    <!-- js placed at the end of the document so the pages load faster -->
    <script src="/rucdbcourse/views/js/bootstrap.min.js"></script>
    <script src="/rucdbcourse/views/js/jquery.scrollTo.min.js"></script>
    <script src="/rucdbcourse/views/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="/rucdbcourse/views/js/jquery-ui-1.9.2.custom.min.js"></script>
    <!--custom switch-->
    <script src="/rucdbcourse/views/js/bootstrap-switch.js"></script>
    <!--custom tagsinput-->
    <script src="/rucdbcourse/views/js/jquery.tagsinput.js"></script>
    <!--custom checkbox & radio-->
    <script type="text/javascript" src="/rucdbcourse/views/js/ga.js"></script>
    <!--common script for all pages-->
    <script src="/rucdbcourse/views/js/common-scripts.js"></script>
    <script src="/rucdbcourse/views/js/sidebar.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/js/num2Chinese.js"></script>
    <script src="/rucdbcourse/views/assets/layer/layer.js"></script>
     
    
    <script type="text/javascript">
    
    var app = angular.module('mindex', ['chieffancypants.loadingBar']).config(function(cfpLoadingBarProvider) {
        cfpLoadingBarProvider.includeSpinner = true;
    });
    app.controller('mindexCtrl', function($scope, $http, $timeout, cfpLoadingBar) {
    	cfpLoadingBar.start();
        $scope.fakeIntro = true;
        $timeout(function() {
        	cfpLoadingBar.complete();
          	$scope.fakeIntro = false;
        }, 750);
       	
      //定义学校数组
        $http({
            method: 'GET',
            url: '../user/getUniversities'
        }).then(function(response) {
            // debugger
            console.log(response)
            $scope.universitiesObj = response.data
            $scope.universities = []
            for (var i = 0; i < $scope.universitiesObj.length; i++) {
                $scope.universities.push($scope.universitiesObj[i].UNAME)
            }
        }, function(error) {
            console.log(error)
        });
      






      //序号
        $scope.sequences = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        $scope.years = [2017, 2018, 2019, 2020]
        $scope.moduleNum = 1;
      
      	$scope.account = "";
      	$scope.accPasswd = "";
       
        
        //添加教师
        $scope.addTeacher = function() {
			console.log("jiaoshi")
			//debugger
			$scope.moduleNum = 1
			console.log($scope.moduleNum)
        };
  
        //管理学生
        $scope.manageStu = function() {
			console.log("jiaoshi")
			$scope.moduleNum = 2
			
        };
       
        //删除学生账户
        $scope.destu = function(){
        	
        };
        
        //删除某个学生的答题记录
        $scope.desturecord = function(){
        	
        };

      //查询某个学生的ID
		$scope.askid = function(){
			  $http.post('../user/askid',
	                    $.param({name:$scope.stuacc4}), {
	                        headers: {
	                            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
	                        }
	                    })
	                .then(function(response) {
	                   
	                    if (response.data.value=="user_not_exist") {
	                        layer.msg("用户名不存在");
	                    } 
	                    else {
	                    	layer.msg(response.data.value);
	                    }
	                }, function(error) {
	                	layer.msg("查询失败，请重试");
	                    console.log(error)
	                });
        };

        
        //根据学生id删除答题记录
        $scope.desturecord_by_id = function(){
            $scope.stuacc3;

            $http.post('../manager/deleteUserRec',
                $.param({
                    userId: $scope.stuacc3
                }),{
                    headers: {
                         'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
                    }
                })
                .then(function(response) {
                   		//alert(response.data);
                        if (response.data==true) {
                            layer.msg("成功");
                        } 
                        else {
                            // console.log(response.data.msg);
                            layer.msg("失败");
                        }
                    }, function(error) {
                    layer.msg("失败");
                    console.log(error)
                });
        };
        
		$scope.submitTeacher = function(){
			  var universityNo = 0;//查询出所选择的学校的代码
              for (var i = 0; i < $scope.universitiesObj.length; i++) {
                  // debugger
                  if ($scope.universitiesObj[i].UNAME == $scope.selectedUniversity) {
                      universityNo = $scope.universitiesObj[i].UNO
                  }
              }
			$scope.teacherid = $scope.selectedYear+universityNo+$scope.selectedSequence;
			$scope.ano = universityNo+$scope.selectedSequence;
			
			//发送注册请求
            $http.post('../manager/addTeacher',
                    $.param({
                    	teacherid:$scope.teacherid,
                        tname: $scope.tname,
                        passwd: $scope.passwd,
                        email: $scope.email,
                        uno: universityNo,
                        major: $scope.major,
                        ano: $scope.ano,
                        op_time:"0",
                        grade:"0",
                        classes:"0"
                    }), {
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
                        }
                    })
                .then(function(response) {
                   
                    if (response.data.value=="success") {
                        layer.msg("添加成功");
                    	$scope.account = $scope.teacherid;
                      	$scope.accPasswd = $scope.passwd;
                    } 
                    else {
                        // console.log(response.data.msg);
                        layer.msg("添加失败，请重试");
                    }
                }, function(error) {
                	layer.msg("添加失败，请重试");
                    console.log(error)
                });
		};

    });
    </script>
</body>

</html>
